package OfferCode;

/**
 * @Author Kechelle
 * @Date 2020/9/10 20:43
 * @Version 1.0
 */
public class Code25 {
    class ListNode {
        private ListNode next;
        private int val;
        public ListNode(int val){
            this.val = val;
        }
    }
    public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
        if(l1 == null){
            return l2;
        }
        if(l2==null){
            return l1;
        }
        ListNode res = null;
        if(l1.val < l2.val){
            res = l1;
            l1.next = mergeTwoLists(l1.next,l2);
        }else{
            res = l2;
            l2.next = mergeTwoLists(l1,l2.next);
        }
        return res;
    }
}
